<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>

<head>
<base href="/">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">


<title>扣费记录-添加</title>
<meta name="keywords" content="扣费记录-添加">
<meta name="description"
	content="扣费记录-添加">

<link rel="shortcut icon" href="favicon.ico">
<link href="static/templet/css/bootstrap.min.css?v=3.3.5"
	rel="stylesheet">
<link href="static/templet/css/font-awesome.min93e3.css?v=4.4.0"
	rel="stylesheet">
<link href="static/templet/css/plugins/iCheck/custom.css"
	rel="stylesheet">
<link href="static/templet/css/animate.min.css" rel="stylesheet">
<link href="static/templet/css/style.min862f.css?v=4.1.0"
	rel="stylesheet">

</head>

<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">

		<div class="row">
			<div class="col-sm-10">
				<div class="ibox float-e-margins">
					<div class="ibox-content">
						<div class="form-horizontal">

							<div class="form-group">
								<label class="col-sm-4 control-label">客户名</label>

								<div class="col-sm-6">
									<input type="text" id="userName" name="userName"
										class="form-control">
								</div>
							</div>
							<div class="hr-line-dashed"></div>

							<div class="form-group">
								<label class="col-sm-4 control-label">扣费金额</label>

								<div class="col-sm-6">
									<input type="number" id="price" name="price"
										class="form-control">
								</div>
							</div>
							<div class="hr-line-dashed"></div>

							<div class="form-group">
								<label class="col-sm-4 control-label">描述</label>

								<div class="col-sm-6">
									<textarea id="remark" name="remark" class="form-control"></textarea>
								</div>
							</div>
							<div class="hr-line-dashed"></div>
							<div class="form-group">
								<div class="col-sm-4 col-sm-offset-4">
									<button class="btn btn-primary" onclick="save()" type="button">保存</button>
									<button class="btn btn-white" onclick="cancel()" type="button">取消</button>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>


	<script src="static/templet/js/jquery.min.js?v=2.1.4"></script>
	<script src="static/templet/js/bootstrap.min.js?v=3.3.5"></script>
	<script src="static/templet/js/content.min.js?v=1.0.0"></script>
	<script src="static/templet/js/iframe.min.js"></script>
	<script src="static/templet/js/plugins/layer/layer.min.js"></script>
	<script src="static/templet/js/plugins/iCheck/icheck.min.js"></script>
	<script src="static/templet/js/plugins/layer/laydate/laydate.js"></script>
	<script type="text/javascript">
		var rechargeTime = {
			elem : "#rechargeTime",
			format : "YYYY-MM-DD hh:mm:ss",
			min : "1970-01-11 00:00:00",
			max : "2099-06-16 23:59:59",
			istime : true,
			istoday : false,
			choose : function(datas) {
				end.min = datas;
				end.start = datas
			}
		};
		laydate(rechargeTime);
		function cancel() {
			iframe.close(0);
		}

		function save() {
			var load = layer.load(1, {
				shade : [ 0.1, '#fff' ]
			});
			var userName = $.trim($("#userName").val());
			if (userName == '') {
				layer.msg('请输入用户名', {
					icon : 1
				});
				layer.close(load);
				return;
			}

			var price = $.trim($("#price").val());
			if (price == '') {
				layer.msg('请输入金额', {
					icon : 1
				});
				layer.close(load);
				return;
			}

			var remark = $.trim($("#remark").val());
			if (remark == '') {
				layer.msg('请输入备注', {
					icon : 1
				});
				layer.close(load);
				return;
			}

			$.post('deduc/child/addDeduc', {
				userName : userName,
				price : price,
				remark : remark
			}, function(data, status) {
				if (status == 'success') {
					var result = data.result;
					var state = result.state;
					layer.close(load);
					if (state == 1) {
						layer.msg('保存成功', {
							icon : 1
						});
						iframe.close(1);
					} else {
						layer.msg(result.message, {
							icon : 1
						});
					}
				}
			})
		}
	</script>
</body>

</html>